<template>
    <div class="edit-announcement-modal">
      <div class="modal-content">
        <h3 style="display: flex;justify-content: center;margin-bottom: 10px;">添加公告</h3>
        <textarea v-model="announcementText" rows="4" placeholder="请输入公告内容"></textarea>
        <div class="modal-actions">
          <button @click="saveAnnouncement">保存</button>
          <button @click="cancelEdit">取消</button>
        </div>
      </div>
    </div>
  </template>
  
  <script>
  export default {
    name: "EditAnnouncement",
    props: {
      initialText: {
        type: String,
        default: "",
      },
    },
    data() {
      return {
        announcementText: this.initialText,
      };
    },
    methods: {
      saveAnnouncement() {
        this.$emit("save", this.announcementText);
      },
      cancelEdit() {
        this.$emit("cancel");
      },
    },
  };
  </script>
  
  <style scoped>
  .edit-announcement-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
  }
  
  .modal-content {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    width: 400px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  }
  
  textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    margin-bottom: 10px;
  }
  
  .modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
  }
  
  button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
  }
  
  button:first-of-type {
    background-color: #45c1f3;
    color: white;
  }
  
  button:last-of-type {
    background-color: #ccc;
    color: #333;
  }
  </style>